package com.fotkidemo.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created with IntelliJ IDEA.
 * User: roma
 * Date: 6/27/12
 * Time: 4:05 AM
 * To change this template use File | Settings | File Templates.
 */

/**
 * Статические методы для работы с ссылками на коллекции пользователя на yandex фотках.
 * Сохранение ссылок на устройстве.
 */
public class ServiceUtil {
    public static final String SERVICE_API_PREFERENCES_ID = "com.fotkidemo.service";
    public static final String SERVICE_ALBUM_LIST_HREF = "album_list_href";

    public static void saveAlbumListHref(Context context, String href) {
        final SharedPreferences storage = context.getSharedPreferences(SERVICE_API_PREFERENCES_ID, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = storage.edit();
        editor.putString(SERVICE_ALBUM_LIST_HREF, href);
        editor.commit();
    }

    public static String getAlbumListHref(Context context) {
        final SharedPreferences storage = context.getSharedPreferences(SERVICE_API_PREFERENCES_ID, Context.MODE_PRIVATE);
        return storage.getString(SERVICE_ALBUM_LIST_HREF, null);
    }

    public static void deleteAlbumListHref(Context context) {
        final SharedPreferences storage = context.getSharedPreferences(SERVICE_API_PREFERENCES_ID, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = storage.edit();
        editor.remove(SERVICE_ALBUM_LIST_HREF);
        editor.commit();
    }
}
